import request from "@/utils/request.ts";
import {
    AddOrUpdateUser,
    AllOrderStateResponseData,
    CertificationTypeResponseData,
    OrderInfoResponseData,
    PayStatus,
    QrCode,
    SubmitOrderResponseData,
    UserInfoResponseData, UserOrderInfoResponseData, UserParams
} from "@/api/user/type.ts";

enum API {
    //提交订单
    SUBMITORDER_URL='/order/orderInfo/auth/submitOrder/',
    //获取订单信息
    GETORDERINFO_URL = 'order/orderInfo/auth/getOrders/',
    //取消订单
    CANCELORDER_URl = '/order/orderInfo/auth/cancelOrder/',

    QRCODE_URl = '/order/weixin/createNative/',
    //查询微信支付状态
    PAYSTATUS_URl = '/order/weixin/queryPayStatus/',

    GETUSERINFO_URL='/user/auth/getUserInfo/',
    //获取证件类型的接口地址
    CERTOFOCATOONTYPE_URL='/cmn/dict/findByDictCode/',
    //用户认证的结构
    USERAUTH_URL = '/user/auth/userAuth',

    USERORDERINFO_URL='/order/orderInfo/auth/',

    ORDERSTATE_URL = '/order/orderInfo/auth/getStatusList',
    // CITY_URL='/cmn/dict/findByParentId/',
    CITY_URL='/cmn/dict/findChildData/',//本地
    ADDUSER_URL = '/user/patient/auth/save/',
    UPDATEUSER_URL = '/user/patient/auth/update/',
    DELETEUSER_URL='/user/patient/auth/remove/'
}

// export const reqSubmitOrder = (hoscode :string,scheduleId:string,patientId:string)=>request.post<any,OrderResponseData>(API.SUBMITORDER_URL+`${hoscode}/${scheduleId}/${patientId}`)
export const reqSubmitOrder = (scheduleId:string,patientId:string)=>request.post<any,SubmitOrderResponseData>(API.SUBMITORDER_URL+`${scheduleId}/${patientId}`);//本地接口

export const reqOrderInfo = (id:string)=>request.get<any,OrderInfoResponseData>(API.GETORDERINFO_URL+id);

export const reqCancelOrderInfo = (id:string) => request.get<any,any>(API.CANCELORDER_URl+id);
export const reqQrCode = (orderId:string) => request.get<any,QrCode>(API.QRCODE_URl+orderId);
export const reqQueryPayStatus = (orderId:string) => request.get<any,PayStatus>(API.PAYSTATUS_URl+orderId);

export const reqGetUserinfo = ()=>request.get<any,UserInfoResponseData>(API.GETUSERINFO_URL);

export const reqCertificatesType = (CertificatesType='CertificatesType')=>request.get<any,CertificationTypeResponseData>(API.CERTOFOCATOONTYPE_URL+CertificatesType);

export const reqUserAuth = (data:UserParams)=>request.post<any,any>(API.USERAUTH_URL,data);
export const reqUserOrderInfo = (page:number,limit:number,patientId:string,orderStatus:string)=>request.get<any,UserOrderInfoResponseData>(API.USERORDERINFO_URL+`${page}/${limit}?patientId=${patientId}&orderStatus=${orderStatus}`);

export const reqOrderState = ()=>request.get<any,AllOrderStateResponseData>(API.ORDERSTATE_URL);
export const reqCity = (parentId:string)=>request.get<any,any>(API.CITY_URL+parentId)
export const reqAddOrUpdateUser = (data:AddOrUpdateUser)=>{
    if(!data.id){
        return request.post(API.ADDUSER_URL,data)
    }else{
        return request.post(API.UPDATEUSER_URL,data);
    }
}
export const reqRemoveUser = (id:number)=>request.delete(API.DELETEUSER_URL+id);
